//
//  ViewController.m
//  沙哈拉FM
//
//  Created by dllo on 15/11/2.
//  Copyright © 2015年 S1mpl3. All rights reserved.
//

#import "ViewController.h"
#import "AFNetworking.h"
#import "FitHeader.h"

@interface ViewController ()<UIScrollViewDelegate>
@property(nonatomic,retain)UIScrollView *scrollView;
@end

@implementation ViewController

-(void)loadView{
    [super loadView];
    NSArray *array = @[@"1.png", @"2.png", @"3.png"];
    self.scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
    _scrollView.pagingEnabled = YES;
    _scrollView.contentSize = CGSizeMake(self.view.frame.size.width * array.count, self.view.frame.size.height);
    _scrollView.showsHorizontalScrollIndicator = NO;
    _scrollView.contentOffset = CGPointMake(0, 0);
    for (NSInteger i = 0; i < array.count; i++) {
        UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(self.view.frame.size.width * i, 0, self.view.frame.size.width, self.view.frame.size.height)];
        imageView.image = [UIImage imageNamed:array[i]];
        [_scrollView addSubview:imageView];
    }
    self.btn = [UIButton buttonWithType:1];
    _btn.frame = CGRectMake(120 * FITWidth , 560 * FITHeight, 135 * FITWidth, 40 * FITHeight);
    [_btn setTitle:@"开始体验" forState:UIControlStateNormal];
    [_btn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [_btn setTintColor:[UIColor colorWithRed:0.27 green:0.29 blue:0.3 alpha:1]];
    [_btn addTarget:self action:@selector(btnClick) forControlEvents:UIControlEventTouchUpInside];
    _btn.layer.borderWidth = 3;
    _btn.layer.borderColor = [UIColor whiteColor].CGColor;
    _btn.hidden = YES;
    _scrollView.delegate = self;
    [self.view addSubview:_scrollView];
    [self.view addSubview:_btn];

}

-(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView{
    if (scrollView.contentOffset.x == self.view.frame.size.width * 2) {
        _btn.hidden = NO;
    }else
        _btn.hidden = YES;
}

-(void)btnClick{
    [self.welcomeDelegate btnAction];
}

- (void)viewDidLoad {
    [super viewDidLoad];
   
    // Do any additional setup after loading the view, typically from a nib.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
